const articles = [
	{"id": 1, "title": "vuex actions mutations getter modules", "enabled": true, "views": 10 },
	{"id": 2, "title": "vue router", "enabled": true, "views": 2 },
	{"id": 3, "title": "es6 webpack", "enabled": true, "views": 10 },
	{"id": 4, "title": "java", "enabled": true, "views": 10 },
	{"id": 5, "title": "csharp", "enabled": true, "views": 10 },
	{"id": 6, "title": "dubble", "enabled": true, "views": 10 },
	{"id": 7, "title": "flask", "enabled": true, "views": 10 },
	{"id": 8, "title": "http basic", "enabled": true, "views": 10 },
	{"id": 9, "title": "foutain", "enabled": true, "views": 10 },
	{"id": 10, "title": "fire", "enabled": true, "views": 10 },
	{"id": 11, "title": "respact", "enabled": true, "views": 10 },
	{"id": 12, "title": "title", "enabled": true, "views": 10 },
	{"id": 13, "title": "babel", "enabled": true, "views": 10 }
]

const pageSize = 5;

let article = {
	getArticles(page, cb) {
		// console.log('api getArticles', page);
		let start = (page - 1) * pageSize;
		let end = page * pageSize
		// console.log(start, end);
		let temp = articles.filter(a => a.id > start && a.id <= end);
		// console.log(temp);
		setTimeout(() => cb(temp), 1000)
	},
	clearHistory(historyList, cb, ecb) {
		setTimeout(() => {
			var r = Math.random();
			console.log('api clearHistory, r: %s', r);
			// console.log(historyList);
			(r > 0.3) 
				? cb()
				: ecb()
		}, 1000);
	},
	enableArticle(id) {
		
	}
}

export default article